package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.model.LoginUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizStationDrawing;
import com.ruoyi.biz.service.IBizStationDrawingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车站图纸Controller
 * 
 * @author cc
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/system/station_drawing")
public class BizStationDrawingController extends BaseController
{
    @Autowired
    private IBizStationDrawingService bizStationDrawingService;

    /**
     * 查询车站图纸列表
     */
    @PreAuthorize("@ss.hasPermi('system:station_drawing:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizStationDrawing bizStationDrawing)
    {
        startPage();
        List<BizStationDrawing> list = bizStationDrawingService.selectBizStationDrawingList(bizStationDrawing);
        return getDataTable(list);
    }

    /**
     * 导出车站图纸列表
     */
    @PreAuthorize("@ss.hasPermi('system:station_drawing:export')")
    @Log(title = "车站图纸", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizStationDrawing bizStationDrawing)
    {
        List<BizStationDrawing> list = bizStationDrawingService.selectBizStationDrawingList(bizStationDrawing);
        ExcelUtil<BizStationDrawing> util = new ExcelUtil<BizStationDrawing>(BizStationDrawing.class);
        util.exportExcel(response, list, "车站图纸数据");
    }

    /**
     * 获取车站图纸详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:station_drawing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizStationDrawingService.selectBizStationDrawingById(id));
    }

    /**
     * 新增车站图纸
     */
    @PreAuthorize("@ss.hasPermi('system:station_drawing:add')")
    @Log(title = "车站图纸", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizStationDrawing bizStationDrawing)
    {
        return toAjax(bizStationDrawingService.insertBizStationDrawing(bizStationDrawing));
    }

    /**
     * 修改车站图纸
     */
    @PreAuthorize("@ss.hasPermi('system:station_drawing:edit')")
    @Log(title = "车站图纸", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizStationDrawing bizStationDrawing)
    {
        return toAjax(bizStationDrawingService.updateBizStationDrawing(bizStationDrawing));
    }

    /**
     * 删除车站图纸
     */
    @PreAuthorize("@ss.hasPermi('system:station_drawing:remove')")
    @Log(title = "车站图纸", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizStationDrawingService.deleteBizStationDrawingByIds(ids));
    }

    /**
     * 根据用户获取车站图纸详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:station_drawing:query')")
    @GetMapping(value = "/getDrawingByUser")
    public AjaxResult getDrawingByUser()
    {
        LoginUser loginUser = getLoginUser();
        return success(bizStationDrawingService.getDrawingByUser(loginUser));
    }


}
